package com.xpgk.mvc.todayyzm;

import java.util.Random;

import com.xpgk.mvc.base.BaseController;
import com.xpgk.mvc.organization.Organization;

public class TodayYZMController extends BaseController{
	public void index(){
		int x=(int)(Math.random()*10000);
		Organization org = Organization.dao.findById(getCUserOrganIds());
		if(org!=null){
			if(org.getStr(Organization.column_todayyzm)!=null){
				setAttr("yzm", org.getStr(Organization.column_todayyzm));
			}else{
				
				org.set(Organization.column_todayyzm, x);
				org.update();
				setAttr("yzm", x);
			}
		}
	
		render("todayyzm.html");
	}
	
	public void refresh(){
		int x=(int)(Math.random()*10000);
		String msg = "200";
		Organization org = Organization.dao.findById(getCUserOrganIds());
		if(org!=null){
			
				org.set(Organization.column_todayyzm, x);
				if(!org.update()){
					msg ="更新失败";
				}
				setAttr("yzm", x);
			
		}
	
		renderText(msg);
	}
	
	

}
